package com.ruoyi.web.controller.wechatApplet;

import com.ruoyi.background.domain.AppWechatUser;
import com.ruoyi.background.service.IAppGradeRecordService;
import com.ruoyi.background.service.IAppWechatUserService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/wechat/user")
public class WechatUserController extends BaseController {

    @Autowired
    private IAppWechatUserService wechatUserService;

    @Autowired
    private IAppGradeRecordService gradeRecordService;


    /**
     * 获取用户的积分
     *
     * @return 用户积分
     */
    @GetMapping("/getUserGrade")
    public AjaxResult getUserGrade() {
        AppWechatUser wechatUser = wechatUserService.selectAppWechatByUserId();
        return AjaxResult.success(wechatUser.getGrade());

    }

    /**
     * 获取用户累计的积分
     *
     * @return 结果
     */
    @GetMapping("/getUserSumGrade")
    public AjaxResult getUserSumGrade() {
        Integer userCountInGrade = gradeRecordService.getUserCountInGrade();
        return AjaxResult.success(userCountInGrade);

    }

}
